#include<stdio.h>

int main()
{
    int a, b, c, d;
    int start, end;
    int hour, min;
    int dur;
    scanf("%d:%d %d:%d",&a, &b, &c, &d);
    start = a*60 + b;
    end = c*60 + d;
    dur = end - start;
    hour = dur/60;
    min = dur%60;
    printf("%d %d",hour, min);

    return 0;

}